﻿using System;
using System.Collections.Generic;
using System.Text;
using System.Windows.Forms;

namespace Red
{
    partial class Frm2
    {
       
        /// <summary>
        /// 初始化 wb控件相关 属性
        /// </summary>
        private void wbInit()
        {
            this.wbQQ1Email.ScriptErrorsSuppressed = true;
            this.wbQQ2Email.ScriptErrorsSuppressed = true;
            this.wbQQ1WB.ScriptErrorsSuppressed = true;
            this.wbQQ1Qzone.ScriptErrorsSuppressed = true;
            this.wb163.ScriptErrorsSuppressed = true;
            this.wb163Email.ScriptErrorsSuppressed = true;
            this.wb163WB.ScriptErrorsSuppressed = true;
            this.wb新浪.ScriptErrorsSuppressed = true;
            this.wb新浪Email.ScriptErrorsSuppressed = true;
            this.wb新浪WB.ScriptErrorsSuppressed = true;
            this.wb百度.ScriptErrorsSuppressed = true;
            this.wbCSDN.ScriptErrorsSuppressed = true;
            this.wbWorkEmail.ScriptErrorsSuppressed = true;
            this.wb天涯.ScriptErrorsSuppressed = true;
            this.wb淘宝.ScriptErrorsSuppressed = true;
            this.wb51.ScriptErrorsSuppressed = true;
            this.webBrowser17.ScriptErrorsSuppressed = true;
            this.webBrowser18.ScriptErrorsSuppressed = true;
            this.webBrowser19.ScriptErrorsSuppressed = true;
            this.webBrowser20.ScriptErrorsSuppressed = true;
            UserInfo.Dictionary.Add("wbQQ1Email", new UserInfo() { UserName = "", Pwd = "" });
            UserInfo.Dictionary.Add("wbQQ2Email", new UserInfo() { UserName = "", Pwd = "" });
            UserInfo.Dictionary.Add("wbQQ1WB", new UserInfo() { UserName = "", Pwd = "" });
            UserInfo.Dictionary.Add("wbQQ1Qzone", new UserInfo() { UserName = "", Pwd = "" });
            UserInfo.Dictionary.Add("wb163", new UserInfo() { UserName = "", Pwd = "" });
            UserInfo.Dictionary.Add("wb163Email", new UserInfo() { UserName = "", Pwd = "" });
            UserInfo.Dictionary.Add("wb163WB", new UserInfo() { UserName = "", Pwd = "" });
            UserInfo.Dictionary.Add("wb新浪", new UserInfo() { UserName = "", Pwd = "" });
            UserInfo.Dictionary.Add("wb新浪Email", new UserInfo() { UserName = "", Pwd = "" });
            UserInfo.Dictionary.Add("wb新浪WB", new UserInfo() { UserName = "", Pwd = "" });
            UserInfo.Dictionary.Add("wb百度", new UserInfo() { UserName = "", Pwd = "" });
            UserInfo.Dictionary.Add("wbCSDN", new UserInfo() { UserName = "", Pwd = "" });
            UserInfo.Dictionary.Add("wbWorkEmail", new UserInfo() { UserName = "wangfei@it.dch.com.cn", Pwd = "qsiofg4nui" });
            UserInfo.Dictionary.Add("wb天涯", new UserInfo() { UserName = "", Pwd = "" });
            UserInfo.Dictionary.Add("wb淘宝", new UserInfo() { UserName = "", Pwd = "" });
            UserInfo.Dictionary.Add("wb51", new UserInfo() { UserName = "", Pwd = "" });
        }

        public void LoadQQ1Email()
        {
            this.wbQQ1Email.Url = new Uri(Urls.adressQQ1Email);
            DoEvents(this.wbQQ1Email);
        }
        private void DoEvents(WebBrowser wb)
        {
            while (wb.ReadyState < WebBrowserReadyState.Complete)
            {
                Application.DoEvents();
            }
        }
        public void LoadQQ2Email()
        {
            this.wbQQ2Email.Url = new Uri(Urls.adressQQ2Email);
            DoEvents(this.wbQQ2Email);
        }
        public void LoadQQ1WB()
        {
            this.wbQQ1WB.Url = new Uri(Urls.adressQQ1WB);
            DoEvents(this.wbQQ1WB);
        }
        public void LoadQQ1Qzone()
        {
            this.wbQQ1Qzone.Url = new Uri(Urls.adressQQ1Qzone);
            DoEvents(this.wbQQ1Qzone);
        }
        public void Load163()
        {
            this.wb163.Url = new Uri(Urls.adress163);
            DoEvents(this.wb163);
            
        }
        public void Load163Email()
        {
            this.wb163Email.Url = new Uri(Urls.adress163Email);
            DoEvents(this.wb163Email);
        }
        public void Load163WB()
        {
            this.wb163WB.Url = new Uri(Urls.adress163WB);
            DoEvents(this.wb163WB);
        }
        public void Load新浪()
        {
            this.wb新浪.Url = new Uri(Urls.adress新浪);
            DoEvents(this.wb新浪);
        }
        public void Load新浪Email()
        {
            this.wb新浪Email.Url = new Uri(Urls.adress新浪Email);
            DoEvents(this.wb新浪Email);
        }
        public void Load新浪WB()
        {
            this.wb新浪WB.Url = new Uri(Urls.adress新浪WB);
            DoEvents(this.wb新浪WB);
        }
        public void Load百度()
        {
            this.wb百度.Url = new Uri(Urls.adress百度);
            DoEvents(this.wb百度);
        }
        public void LoadCSDN()
        {
            this.wbCSDN.Url = new Uri(Urls.adressCSDN);
            DoEvents(this.wbCSDN);
            
        }
        public void LoadWorkEmail()
        {
            this.wbWorkEmail.Url = new Uri(Urls.adressWorkEmail);
            DoEvents(this.wbWorkEmail);
            this.tcTablControl.SelectedTab = this.tpWorkEmail;
            UserInfo ui = UserInfo.Dictionary["wbWorkEmail"];
            HtmlDocument doc= this.wbWorkEmail.Document;
            doc.GetElementById("Username").SetAttribute("value",ui.UserName);
            doc.GetElementById("Password").SetAttribute("value", ui.Pwd);
            foreach (HtmlElement element in this.wbWorkEmail.Document.GetElementsByTagName("input"))
            {
                if (element.GetAttribute("type") == "submit")
                {
                    element.InvokeMember("click");
                    break;
                }
            }

        }
        public void Load天涯()
        {
            this.wb天涯.Url = new Uri(Urls.adress天涯);
            DoEvents(this.wb天涯);
        }
        public void Load淘宝()
        {
            this.wb淘宝.Url = new Uri(Urls.adress淘宝);
            DoEvents(this.wb淘宝);
        }
        public void Load51()
        {
            this.wb51.Url = new Uri(Urls.adress51);
            DoEvents(this.wb51);
        }
    }
}
